<template>
	<view class="wrap">
		<ErrDialog v-if="errDialogOpen" ref="errDialog" :dialogData="dialogData" @retryFunciton="retryFunciton">
		</ErrDialog>
		<!-- <PdaScan></PdaScan> -->
		<!-- :is-scroll="true" -->
		<u-tabs :list="list" :current="current" @change="change"></u-tabs>
		<!-- 当前套餐 -->
		<view v-if="current === 0" style="padding-bottom: 140rpx;">
			<view class="example-body">
				<u-form>
					<!-- <u-form-item label="库房" label-width="170">
					<uni-data-select placeholder="请输入库房" v-model="form.kuf_no" :localdata="kufList"
						@change="changeKuf"></uni-data-select>
				</u-form-item>
				<u-form-item label="区域" label-width="170">
					<uni-data-select placeholder="请输入区域" :disabled="notChangeQuyNo" v-model="form.quy_no"
						:localdata="quNoList" @change="changeQuyNo"></uni-data-select>
				</u-form-item> -->
					<u-form-item label="商品" label-width="170">

						<u-input class="my-input" @click="changeScanInput('form.goodsid')" v-model="form.goodsid"
						style="margin-right: 10rpx;"	placeholder="请输入商品编号"></u-input>
						<u-button @click="scan1('goodsid')">扫描</u-button>

					</u-form-item>
					<u-form-item label="数量" label-width="170">

						<u-input class="my-input" v-model="form.amount" @click="changeScanInput('form.amount')"
							type="number" placeholder="请输入数量"></u-input>
					</u-form-item>
					<u-form-item label="隔膜柜编码" label-width="170">
						<u-input class="my-input" @click="changeScanInput('form.gmgno')" v-model="form.gmgno"
							style="margin-right: 10rpx;" placeholder="请输入隔膜柜编码"></u-input>
						<u-button @click="scan1('gmgno')">扫描</u-button>
					</u-form-item>
				</u-form>
			</view>
			<u-row gutter="32" class="more-bottom-box" justify="center">
				<u-col span="10">
					<view>
						<u-button class="more-button" type="primary" shape="circle"
							@click="submitGm('In')">提交隔膜入库</u-button>
					</view>
				</u-col>
			</u-row>
		</view>
		<view v-if="current === 1" class="" style="padding-bottom: 140rpx;">
			<view class="example-body">
				<u-form>
			
					<u-form-item label="卷绕机" label-width="170">
						<u-input class="my-input" @click="changeScanInput('form.goodsidCK')" v-model="form.goodsidCk"
							style="margin-right: 10rpx;" placeholder="请输入卷绕机编码" @blur="blurFunction" ></u-input>
						<u-button @click="scan1('goodsidCk')">扫描</u-button>
					</u-form-item>
				
					<u-form-item label="隔膜柜编码" label-width="170">
						<u-input class="my-input" @click="changeScanInput('form.gmgnoCk')" v-model="form.gmgnoCk"
							style="margin-right: 10rpx;" placeholder="请输入隔膜柜编码" @blur="blurFunction"></u-input>
						<u-button @click="navTo('/pages/sys/diaphragm/list')">选择</u-button>
					</u-form-item>
					<u-gap height="20" bg-color="#f5f5f5"></u-gap>
								
					
				</u-form>
			</view>
			<view v-show="showHeight" style="margin: 460rpx;"></view>
			
			<u-row gutter="32" class="more-bottom-box" justify="center">
		
				<u-col span="10">
					<view>
						<u-button class="more-button" type="primary" shape="circle"
							@click="submitGm('Out')">提交隔膜出库</u-button>
					</view>
				</u-col>
			</u-row>
		</view>
		<!-- <u-row v-if="current === 1" gutter="32" class="more-bottom-box" justify="center">
			<u-col span="10">
				<view><u-button :disabled="!huojGoodsList.length" class="more-button" type="primary" shape="circle"
						@click="submitCheck('returnSearch')">提交并返回货位列表</u-button>
				</view>
			</u-col>
			<u-col span="10">
				<view><u-button :disabled="!huojGoodsList.length" class="more-button" type="primary" shape="circle"
						@click="submitCheck()">提交</u-button>
				</view>
			</u-col>
		</u-row> -->
		<view v-if="current === 2" style="padding-bottom: 120rpx;">


			<u-form :model="form">

				test

			</u-form>
			<u-row gutter="32" class="more-bottom-box" justify="center">
				<u-col span="10">
					<view>
						<u-button class="more-button" type="primary" shape="circle"
							@click="scan1('tpbar')">扫入库单</u-button>
					</view>
				</u-col>
				<u-col span="10">
					<view><u-button class="more-button" type="primary" shape="circle" @click="submitIn">下架</u-button>
					</view>
				</u-col>

			</u-row>
		</view>
	</view>
</template>
<script>
	import ErrDialog from '@/components/err-dialog.vue'
	export default {
		components: {
			ErrDialog
		},

		data() {
			return {
				// 给一个初始值
				scanInput: '',
				scanResult: '',
				notChangeQuyNo: true,
				form: {
					kuf_no: '',
					quy_no: '',
					gztid: '',
					tpNum: '1',
					//1：空托入库2：空托出库
					czlx: '1',
					landpoint: 'DHJ01',
					tpbar: '',
					gdname: '',
					goodsid: '',
					amount: '',
					gmgno: '',
					
					goodsidCk:'',
					gmgnoCk:'',
				},
				goodsid: '',
				errDialogOpen: false,
				// 提示信息
				dialogData: {
					title: '出库',
					msgType: '',
					errContent: '',
					confirmText: '',
					functionName: '',
					cancelText: '',
					closeFunction: '',
				},
				//是否为正常物料
				ISZCGD: '',
				keywords: '',
				// form: {
				// 	huoz_id: '',
				// 	tpbar: '',
				// 	itm: '',
				// 	rwid: '',
				// },
				border: true,
				show: false,
				//库房展示
				kufShow: false,

				// 工作台下拉展示
				gzzShow: false,
				// 当前工作台中文
				gztNowLabel: '',
				GZTID: '',

				// 被选中的商品明细下标
				selectItemIndex: '',
				// 托盘的商品明细
				// huojGoodsList: [],
				// 货架上的货位商品明细
				huojGoodsList: [],
				//选中的明细
				SEQNO: '',
				// 选中的货架号
				HUOJNO: '',
				//选中的货架面
				ORIENTATIONS: '',
				//当前选中的托盘号
				tpbar: '',
				showHeight:false,
				kuf: '',
				// 商品相关条件
				goods: '',
				//库房
				kufList: [],
				//区域
				quNoList: [],
				//库别
				kubList: [],
				//工作台
				gztList: [],
				// 隔膜集合
				gmList: [],
				// 过滤后的新隔膜集合
				gmListNew: [],
				//日历选择显示
				calendaShow: false,
				//有效期日历显示
				calendaEffdateShow: false,
				list: [{
					name: '隔膜入库'
				}, {
					name: '隔膜出库',
				}],

				m2mSimflowList: [],
				m2mOrderFlowList: [],
				current: 0,
				result1: '',
				status: 'nomore',
				iconType: 'circle',
				isDot: false,
				loadText: {
					loadmore: '点击加载更多',
					loading: '正在加载...',
					nomore: '没有更多了'
				},
				// 搜索栏的托盘号
				tpbar: '',
				nvueWidth: 730,
				only_one: [{
					text: '选择此项',
					value: 0
				}],
				// 基础表单数据
				baseFormData: {
					name: '',
					age: '',
					introduction: '',
					sex: 2,
					hobby: [5],
					datetimesingle: 1627529992399
				},
				// 汇总信息存储
				hzData: {

				},
				// 点击的汇总下标
				hzIndex: '',
				refreshInHead: true,
				refreshMxMsg: true,
				hzList: [],

				oneMx: {},
				disableTrue: true,
				// 入库点
				landpoint: '',
				sjAmouont: '1',
				sjLocation: '',
			}
		},
		onUnload() {
			// 移除监听事件
			uni.$off('scancodedate')
		},
		
		onLoad(option) {
			
			if (option) {
				
				if (option.item) {
					this.current = 1
					this.form.goodsidCk = uni.getStorageSync("diaphragm-goodsidCk")
					this.form.gmgnoCk = uni.getStorageSync("diaphragm-gmgnoCk")
					let item = JSON.parse(option.item)
					// this.hzData = item
					console.log('收到的:' + JSON.stringify(item))
					if("back" == item){
						console.log("没有选择,就是退出")
						return
					}
					console.log('收到的:' + item.LOCATION)
					this.form.gmgnoCk = item.LOCATION;
					uni.setStorageSync("diaphragm-gmgnoCk",this.form.gmgnoCk)
					return
				}
			}
			
			this.updageFrom()
			var _this = this
			uni.$on("scancodedate", async (res) => {
				console.log("out出库页面监听到的async:" + res); //我是全局事件订阅的调用方法
				this.scanResult = JSON.stringify(res);
				setTimeout(() => {
					this.changeScanValue()
					
				}, 200);


			})
		},


		created() {
			// this.getKuf(2)
			// this.getKuf(3)
			// this.getGzt()
			// this.init()
			// this.searchHz()
			this.getGmList()
		},
		// 数据变化适用
		onShow() {
			this.myShow()

		},
		onBackPress() {
			console.log("点击了返回")
			uni.switchTab({
				url: "/pages/sys/workbench/wms-work"
			})
			return true
		},
		methods: {
			gmListFilter(e) {
				// 传入的Vue是没问题的,但是uni-app会延时,导致输入的结果和打印的结果有时间误差，不一致！
				// console.log(this.tpbar)
				// uni-app框架官方说明：input事件处理函数内实时修改当前值不生效，可以延迟设置！
				// 延时的结果,输入的结果和打印的结果一致！
				setTimeout(() => {
					console.log(+this.goodsid)
					let tabs = this.gmList
					let goodsid = this.goodsid
					// this.editableTabs = tabs.filter(tab => tab.name !== targetName);
					// DHJ000000006   str.includes("Tara")
					this.gmListNew = tabs.filter(tab => tab.GDSEQ.includes(goodsid));
					if (this.gmListNew.length < 1 && this.gmList.length > 0) {
						this.$u.toast('没有对应数据,请重新输入商品号')
					}
					console.log(JSON.stringify(this.gmListNew))
				}, 10)
			
				// 这种方式是uni-app官方的方式,测试结果正确！
				// console.log(e+"")
			},
			// 判定点击的哪个输入框
			changeScanInput(inputItem) {
				console.log(inputItem)
				this.scanInput = inputItem
				//this.$u.toast(JSON.stringify(inputItem))
			},
			// 扫描后执行的方法,判断输入框并绑定值,可以自行跳转,或者扫描完执行某方法,
			changeScanValue() {
				let scanInput = this.scanInput
				let result = JSON.parse(this.scanResult)
				if ("form.tpbar" === scanInput) {
					console.log("this.form.tpbar ")
					this.form.tpbar = result
				} else if ("sjAmouont" === scanInput) {
					console.log("this.sjAmouont")
					this.sjAmouont = result
				} else if ("inbillNo" === scanInput) {
					console.log("this.inbillNo")
					this.inbillNo = result
				} else if ("form.goodsid" === scanInput) {
					console.log("form.goodsid:" + result)
					this.form.goodsid = result
				} else if ("form.gmgno" === scanInput) {
					console.log("form.gmgno")
					this.form.gmgno = result
				} else if ("form.amount" === scanInput) {
					console.log("form.amount")
					this.form.amount = result
				} else if ("goodsid" === scanInput) {
					console.log("goodsid")
					this.goodsid = result
				} else if ("form.goodsidCK" === scanInput) {
					console.log("form.goodsidCK")
					this.form.goodsidCK = result
				}else if ("form.gmgnoCk" === scanInput) {
					console.log("form.gmgnoCk")
					this.form.gmgnoCk = result
				}else {
					//form.gmgnoCk
					//form.goodsidCK
					//form.goodsid
					// this.$u.toast('没有预先适配:' + scanInput)
					console.log('没有预先适配:' + scanInput)
				}
			},
			// 选中某个单选框时，由radio时触发
			radioChange(e) {
				console.log(e);
				this.selectItemIndex = e
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				console.log("SEQNO:" + this.SEQNO)
				console.log("radioGroupChange:" + e);
				this.oneMx = this.huojGoodsList[e]
				console.log("单选选择的明细:" + JSON.stringify(this.oneMx))
			},
			navTo(url) {
				// uni.navigateTo({
				// 	url: url
				// });
				// uni.switchTab({
				// 	url: url
				// });
				
				uni.switchTab({
					url: url,
					success: function(e) {
						// console.log("heleo")
						// this.updageFrom()
						
						var page = getCurrentPages().pop(); // 返回页面数组的最后一个页面数据
						if (page == undefined || page == null)
							return; //如果最后一个页面为undefined或null，即当前就在首页 return出去，不调用onLoad
						page.onLoad();
					}
				});


			},
			// 
			getGmList() {
				//1、IV\_KUF\_NO 库房
				// 2、IV\_QUY\_NO 区域
				// 3、IV\_GDSEQ 商品
				const kuf_no = '%'
				const quy_no = '%'
				const gdseq = this.form.goodsid ? this.form.goodsid :"%"
				
				let param = kuf_no + "," + quy_no + "," + gdseq ;
				console.log(param)
				this.$u.api.general({
						iv_code: "PDAGETGMGHW",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						
						if (res.success) {
							let data = res.data
							console.log("getGmList返回的data:" + JSON.stringify(data))
							//补充text
							this.gmList = data.map(v => {
								this.$set(v, 'text', v
									.GDNAME + "(" + v.GDSEQ + ")"
								) // https://vuejs.org/v2/guide/reactivity.html
								// this.$set(v, 'text', v.KUF_NO)
								this.$set(v, 'value', v.GDSEQ)
								// return v
								return v
							})
						} else {
							this.$u.toast(res.msg);
						}
						// this.gztList.push({
						// 	"text": "DHJ01",
						// 	"WORKLOAD": "4",
						// 	"CENG": "1",
						// 	"GZT_TYPE": "1",
						// 	"ISZCQFP": "N",
						// 	"STORAGEID": "SU3",
						// 	"WORKSTATION_TYPE": "0",
						// 	"LETDOWNFLAG": "1",
						// 	"GZTID": "DHJ01",
						// 	"GZTNAME": "DHJ01测试工作站",
						// 	"KUF_NO": "LHK"
						// })
					});
			},
			searchHz() {
				// this.getInListOneInfo()
				// this.getOutTpbarList()
				// this.getCheckList()
				this.getCheckList()
			},
			overStyle(over) {
				if (over) {
					return "text-align: right;color: #58ca93;";
				} else {
					return "text-align: right;color: #f28c03;";
				}
			},
			init() {
				this.GZTID = uni.getStorageSync('IN_GZTID')
				this.kuf = uni.getStorageSync('kuf')
			},
			goTo(item, index) {
				if (item.over) {
					this.$u.toast('已完成')
					return
				} else {
					let item = this.hzList[index]
					// 如果托盘号填写了 ,则不用改,如果为空,则把选中的托盘号放进去
					// if (this.tpbar.length > 0) {

					// } else {
					// 通过点击明细,输入了入库单号,以及 预览的一些数据
					// this.tpbar = item.TPBAR
					// this.getInListBytpbar()
					// this.tpbar = item.TPBAR
					// }
					this.hzData = item
					this.hzIndex = index
					this.getLocationMxList(item)
					console.log('item:' + JSON.stringify(item))
					item.index = Number(index + 1)
					// this.oneMx = item
					// tabs转换到第一个
					this.change(1)
				}

				// let id = item.INPAGENO
				// uni.navigateTo({
				// 	url: 'index?item=' + JSON.stringify(item)
				// });
			},
			// 根据货架号和货架面获取货位数据
			getOutInfoByTpbar() {
				// 1、IV\_USER\_ID 用户编号,
				// 2、IV\_HUOJNO 货架号
				// 3、IV\_ORIENTATIONS 货架朝面

				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.HUOJNO ? this.HUOJNO : "%"
				const ORIENTATIONS = this.ORIENTATIONS ? this.ORIENTATIONS : "%"

				let param = USER_ID + "," + GZTID + "," + ORIENTATIONS;
				console.log("iv_parm:" + param)
				this.$u.api.general({
						iv_code: "GETSTOCKHJ",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("返回的data:" + JSON.stringify(data))
						if (res.success) {
							this.huojGoodsList = data
							// 默认选中第一个
							this.SEQNO = data[0].SEQNO
							this.oneMx = data[0]
							//是否新批次出库第一托
							// this.isFirshOut()
							// this.hzData = data[0]
							// if (this.list.length < 1) {
							// 	this.$u.toast("没有查到数据");
							// }
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			// // 根据托盘号,获取出库商品明细集合   返回集合后,获取到物料号后,询问第一个物料
			// getOutInfoByTpbar() {
			// 	//1、IV\_STAFF 用户id
			// 	// 2、IV\_GZTID 工作站
			// 	// 3、IV\_BARCODE 托盘号，单号

			// 	const USER_ID = uni.getStorageSync('USER_ID')
			// 	const GZTID = this.GZTID ? this.GZTID : "%"
			// 	const tpbar = this.tpbar ? this.tpbar : "%"

			// 	let param = USER_ID + "," + GZTID + "," + tpbar;
			// 	console.log("iv_parm:" + param)
			// 	this.$u.api.general({
			// 			iv_code: "PDAOUTTPBARMX",
			// 			iv_parm: param
			// 		})
			// 		.then(res => {
			// 			// console.log("返回的res:" + JSON.stringify(res))
			// 			let data = res.data
			// 			console.log("返回的data:" + JSON.stringify(data))
			// 			if (res.success) {
			// 				this.huojGoodsList = data
			// 				// 默认选中第一个
			// 				this.SEQNO = data[0].SEQNO
			// 				this.oneMx = data[0]
			// 				//是否新批次出库第一托
			// 				// this.isFirshOut()
			// 				// this.hzData = data[0]
			// 				// if (this.list.length < 1) {
			// 				// 	this.$u.toast("没有查到数据");
			// 				// }
			// 			} else {
			// 				this.$u.toast(res.msg);
			// 			}
			// 		});
			// },
			getKuf(type) {
				const USER_ID = uni.getStorageSync('USER_ID')
				const KUB = '%'
				const KUF_NO = "%"
				// if(type == "3"){
				// 	KUF_NO = this.form.kuf_no ? this.form.kuf_no : '%'
				// }
				//1获取库别，2获取库房，3获取区域
				const GET_TYPE = type
				let param = USER_ID + "," + KUB + "," + KUF_NO + "," + GET_TYPE;
				this.$u.api.general({
						iv_code: "GETKUFQUYNO",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("kuf返回的data:" + JSON.stringify(data))
						console.log("type:" + type)
						if (res.success) {
							//补充text
							// this.kufList = data
							console.log("type:" + type)
							if (type == "2") {
								this.kufList = data.map(v => {
									this.$set(v, 'text', v.KUF_NO)
									this.$set(v, 'value', v.KUF_NO)
									return v
								})
								// console.log("this.kufList:"+JSON.stringify(this.kufList))
							} else if (type == "3") {
								this.quNoList = data.map(v => {
									this.$set(v, 'text', v.QUY_NO)
									this.$set(v, 'value', v.QUY_NO)
									return v
								})
							} else {
								this.kubList = data.map(v => {
									this.$set(v, 'text', v.KUB)
									this.$set(v, 'value', v.KUB)
									return v
								})
							}

						} else {
							this.errContent = res.msg
							this.$u.toast(res.msg);
						}
					});
			},
			// 是否新批次出库第一托?
			isFirshOut() {
				// 1、IV\_STAFF 用户id
				// 2、IV\_GOODSID 商品id
				// 3、IV\_ITEMID 批次
				// 4、IV\_BATCHNO 批号
				// 5、IV\_OUT\_LX 出库场景类型
				// 6、IV\_CKJH 出库下发：1，拣货2
				const USER_ID = uni.getStorageSync('USER_ID')

				const GOODSID = this.oneMx.GOODSID ? this.oneMx.GOODSID : "%"
				const ITEMID = this.oneMx.ITEMID ? this.oneMx.ITEMID : "%"
				const BATCHNO = this.oneMx.BATCHNO ? this.oneMx.BATCHNO : "%"
				const OUT_LX = this.oneMx.OUTTYPE ? this.oneMx.OUTTYPE : "%"
				const CKJH = 2
				let param = USER_ID + "," + GOODSID + "," + ITEMID + "," +
					BATCHNO + "," + OUT_LX + "," + CKJH;
				console.log("iv_parm:" + param)
				this.$u.api.general({
						iv_code: "PDAGETFIRSTOUTFLG",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("返回的data:" + JSON.stringify(data))
						if (res.success) {
							// this.hzData = data[0]
							// if (this.list.length < 1) {
							// 	this.$u.toast("没有查到数据");
							// }

							// 如果是第一次出库,进行提示
							if (data.ISFIRSTOUT == 'Y') {
								this.dialogData = {
									title: '出库检测(第一托?)',
									msgType: 'warn',
									errContent: '本明细是新批次出库第一托',
									confirmText: '继续进行出库(判断是否为正常物料)',
									// 如果选右边的执行的返回方法
									functionName: 'isNarmalGoods',
									cancelText: '关闭',
								}
								this.errDialogShow()
								this.ISZCGD = data.ISZCGD
								// if(data.ISZCGD=='Y'){
								// 	this.ISZCGD = 'Y'
								// }
							} else {
								this.submitOut()
							}

						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			retryFunciton(e) {
				console.log("子组件返回的e:" + e)
				if (e == "isNarmalGoods") {
					this.isNarmalGoods()
				} else if (e == "submitCheck") {
					this.submitCheck()
				} else if (e == 'submitGmIn') {
					this.submitGm('in')
				} else if (e == 'submitGmOut') {
					this.submitGm('out')
				}
			},
			// 是否是
			isNarmalGoods() {
				if (this.ISZCGD == 'Y') {
					// (对应PDA弹窗提醒)
					this.dialogData = {
						title: '出库检测(正常物料?)',
						msgType: 'warn',
						errContent: '本明细是正常物料',
						confirmText: '我知道了',
						// 如果选右边的执行的返回方法
						functionName: 'submitOut',
						cancelText: '关闭',
					}
					this.errDialogShow()
				} else if (this.ISZCGD == 'N') {
					// 对应pda弹窗选择确认
					this.dialogData = {
						title: '出库检测(正常物料?)',
						msgType: 'error',
						errContent: '本明细不是正常物料',
						confirmText: '同意此物料不是正常物料',
						// 如果选右边的执行的返回方法
						functionName: 'submitOut',
						cancelText: '拒绝',
						closeFunction: 'noNormalGoods',

					}
					this.errDialogShow()
				} else {
					this.$u.toast('ISZCGD未知,严重错误,请排查isFirshOut()返回值')
				}
			},
			noNormalGoods() {
				this.$u.toast('点击了否,不同意')
			},
			// // 是正常物料的弹窗提示(权限控制,指定账号弹窗)
			// isToast(){

			// },
			errDialogShow() {
				console.log("刷新显示提示框")
				//刷新显示
				let that = this;
				that.errDialogOpen = false;
				that.$nextTick(() => {
					that.errDialogOpen = true;
				})

			},
			// getInListBytpbar() {
			// 	const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
			// 	const huoz_id = "%"
			// 	const USER_ID = uni.getStorageSync('USER_ID')
			// 	const inbillNumber = this.tpbar ? this.tpbar : "%"

			// 	const unit = "%"
			// 	const goodsId = "%"
			// 	const palletNumber = "%"
			// 	let param = STORAGE_ID + "," + huoz_id + "," + USER_ID + "," +
			// 		inbillNumber + "," + unit + "," + goodsId + "," + palletNumber;
			// 	console.log("iv_parm:" + param)
			// 	this.$u.api.general({
			// 			iv_code: "PDAINBILLINPAGENO",
			// 			iv_parm: param
			// 		})
			// 		.then(res => {
			// 			// console.log("返回的res:" + JSON.stringify(res))
			// 			let data = res.data
			// 			console.log("返回的data:" + JSON.stringify(data))
			// 			if (res.success) {
			// 				this.hzData = data[0]
			// 				// if (this.list.length < 1) {
			// 				// 	this.$u.toast("没有查到数据");
			// 				// }
			// 			} else {
			// 				this.$u.toast(res.msg);
			// 			}
			// 		});
			// },
			//重新加载子组件
			myShow() {

				console.log("this.hzData==>" + JSON.stringify(this.hzData))
				//刷新显示
				let that = this;
				that.refreshInHead = false;
				that.$nextTick(() => {
					that.refreshInHead = true;
				})

			},
			myMxShow() {
				//刷新显示
				let that = this;
				that.refreshMxMsg = false;
				that.$nextTick(() => {
					that.refreshMxMsg = true;
				})

			},

			scan1(param) {
				console.log("扫描")
				// #ifdef H5
				this.$u.toast('H5页面不支持扫码,请用安卓等移动设备重试')
				// #endif
				let that = this;
				// 允许从相机和相册扫码
				uni.scanCode({
					success: function(res) {
						if (param == "tpbar") {
							that.tpbar = res.result;
						} else if (param == "LOCATIONZD") {
							that.sjLocation = res.result
						} else if (param == "goodsid") {
							that.form.goodsid = res.result
						} else if (param == "gmgno") {
							that.form.gmgno = res.result
						}else if (param == "goodsidCk") {
							that.form.goodsidCk = res.result
						}


					}
				});
			},
			change(index) {
				console.log(this.current)
				this.current = index;
			},
			submit(index) {
				if (this.tpbar) {
					this.$u.toast('调用下架接口')
				} else {
					this.$u.toast('请补充入库单号的数据')
				}
			},
			// 下拉内容是否展开
			showSelector(res) {
				console.log(res)
				this.showHeight = res
			},
			// 提交隔膜出入库
			submitGm(inOrOut) {
				let myCode = ""
				let myTitle = ""
				let GMGNO ="%"
				let YCLNO ="%"
				if (inOrOut == 'In') {
					myCode = "XBCGMYCLRK"
					myTitle = "隔膜入库提交"
					GMGNO = this.form.gmgno 
					YCLNO = this.form.goodsid
				} else {
					myCode = "XBCGMYCLCK"
					myTitle = "隔膜出库提交"
					GMGNO = this.form.gmgnoCk 
					YCLNO = this.form.goodsidCk
				}
				// 1、IV\_STAFF 作业人员
				// 2、IV\_GMGNO 隔膜柜
				// 3、IV\_YCLNO 原材料条码
				// 4、IV\_AMOUNT 数量

				console.log("oneMx=>" + JSON.stringify(this.oneMx))
				const USER_ID = uni.getStorageSync('USER_ID')
				 
				if(!GMGNO){
					this.$u.toast('隔膜柜信息为空,请确认');
					return;
				}
				const AMOUNT = this.form.amount ? this.form.amount : "0"
				let param = USER_ID + "," +
					GMGNO + "," +
					YCLNO + "," +
					AMOUNT

				console.log("iv_parm:" + param + ";")
				let that = this
				this.$u.api.prcutlexecvar({
						iv_code: myCode,
						iv_parm: param,
						ov_var1: '2',
						ov_var2: '2',
						ov_var3: '2',
						ov_var4: '2',
						ov_var5: '2',
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))

						if (res.success) {
							that.$u.toast(res.msg);
							this.submitSuccess()
						} else {
							this.dialogData = {
								title: myTitle,
								msgType: 'error',
								errContent: res.msg,
								confirmText: '重新提交',
								// 如果选右边的执行的返回方法
								functionName: 'submitGm' + inOrOut,
								cancelText: '关闭',
								closeFunction: '',
							}
							this.errDialogShow()
						}

					});
			},

			submitCheck(paramReturn) {


				// 1、IV\_STAFF 人员
				// 2、IV\_PDNO 盘点单号
				// 3、IN\_SORTSN 行号
				// 4、IV\_JS 件数
				// 5、IV\_LSS 零散数
				// 6、IN\_AMOUNT 实盘数量

				console.log("oneMx=>" + JSON.stringify(this.oneMx))
				const USER_ID = uni.getStorageSync('USER_ID')
				const PDNO = this.oneMx.PDNO ? this.oneMx.PDNO : "%"
				const SORTSN = this.oneMx.SORTSN ? this.oneMx.SORTSN : "%"
				const JS = 0
				const LSS = this.oneMx.AMOUNT ? this.oneMx.AMOUNT : "0"
				const AMOUNT = this.oneMx.AMOUNT ? this.oneMx.AMOUNT : "0"


				let param = USER_ID + "," +
					PDNO + "," +
					SORTSN + "," +
					JS + "," +
					LSS + "," +
					AMOUNT;

				console.log("iv_parm:" + param + ";")
				let that = this
				this.$u.api.prcutlexecvar({
						iv_code: "PDRWQR",
						iv_parm: param,
						ov_var1: '2',
						ov_var2: '2',
						ov_var3: '2',
						ov_var4: '2',
						ov_var5: '2',
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))
						that.$u.toast(res.msg);
						if (res.success) {

							let data = res.data
							// console.log("返回的data:" + JSON.stringify(data))
							console.log("返回的res.msg:" + res.msg)
							this.submitSuccess()
							if (paramReturn == "returnSearch") {
								this.current = 0
							}
						} else {
							this.dialogData = {
								title: '盘点提交',
								msgType: 'error',
								errContent: res.msg,
								confirmText: '重新提交',
								// 如果选右边的执行的返回方法
								functionName: 'submitCheck',
								cancelText: '关闭',
								closeFunction: '',
							}
							this.errDialogShow()
						}

					});
			},
			submitOutBefore() {
				//是否新批次出库第一托
				this.isFirshOut()
			},

			// 提交成功后，刷新汇总集合，如果包含locationid 老的，
			// 那说明这个盘点单还没做完，直接获取明细，
			// 如果不包含，那么提示已经做完，并且跳转到汇总选择页面，供用户选择
			submitSuccess() {
				this.form = {
					kuf_no: '',
					quy_no: '',
					gztid: '',
					tpNum: '1',
					//1：空托入库2：空托出库
					czlx: '1',
					landpoint: '',
					tpbar: '',
					gdname: '',
					goodsid: '',
					amount: '',
					gmgno: '',
					
					goodsidCk:'',
					gmgnoCk:'',
				}


			},
			navTo(url) {
				uni.navigateTo({
					url: url
				});
			},
			// 根据货位进行搜索
			getLocationMxList(item) {

				// 1、IV\_STAFF 人员
				// 2、IV_LOCATIONID 货位
				const USER_ID = uni.getStorageSync('USER_ID')
				const locationid = item.LOCATIONID

				let param = USER_ID + "," + locationid;

				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "GETPDHWDETAILDISP",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.huojGoodsList = data
							this.oneMx = this.huojGoodsList[0]

							this.status = 'nomore';
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			// 获取盘点任务列表
			getCheckList() {
				// 1、IV\_STAFF 人员
				// 2、IV\_GZTID 工作台
				// 3、IV\_STORAGEID 仓库
				// 4、IV\_KUF\_NO 库房
				// 5、IV\_QUY\_NO 区域
				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.GZTID ? this.GZTID : "%"
				const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				const kuf_no = this.form.kuf_no ? this.form.kuf_no : '%'
				const quyu_no = this.form.quyu_no ? this.form.quyu_no : '%'
				let param = USER_ID + "," + GZTID + "," + STORAGE_ID +
					"," + kuf_no + "," + quyu_no;
				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "GETPDHWDISP",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.hzList = data
							if (this.hzList.length < 1) {
								this.$u.toast("暂无数据");
							}
							this.status = 'nomore';


						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			getOutTpbarList() {
				// 1、IV\_STAFF 用户id
				// 2、IV\_GZTID 工作站
				// 3、IV\_YEW\_TYPE业务类型2：出库
				// const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				// // const USER_GH = uni.getStorageSync('USER_GH')
				// const yez_id = this.form.huoz_id ? this.form.huoz_id : "%"
				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.GZTID ? this.GZTID : "%"
				const yew_type = '2'
				let param = USER_ID + "," + GZTID + "," + yew_type;
				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "PDAOUTTPBAR",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						// console.log("返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.hzList = data

							this.status = 'nomore';


						} else {
							this.$u.toast(res.msg);
						}
					});
			},

			blurFunction() {
				console.log("失去了焦点")
				// this.myMxShow()
				this.updageFrom()
			},
			
			// 更新from
			updageFrom(){
				 uni.setStorageSync("diaphragm-goodsidCk",this.form.goodsidCk)
				console.log("出库卷绕机 缓存:"+uni.getStorageSync("diaphragm-goodsidCk"))
				
				uni.setStorageSync("diaphragm-gmgnoCk",this.form.gmgnoCk)
				console.log("出库隔膜 缓存:"+uni.getStorageSync("diaphragm-gmgnoCk"))
			},
			changeProductDate(e) {
				console.log("选择的日期:" + JSON.stringify(e))
				this.oneMx.PRODUCTDATE = e.result
				this.myMxShow()
			},
			changeEFFDATE(e) {
				this.oneMx.EFFDATE = e.result
				this.myMxShow()
			},
			changeGzt(index) {
				// 表层文字
				this.gztNowLabel = this.gztList[index].text;
				uni.setStorageSync('gztNowLabel', this.gztNowLabel)

				// id
				const GZTID = this.gztList[index].GZTID == "%" ? '' : this.gztList[index].GZTID;
				if (GZTID) {
					this.GZTID = GZTID
					uni.setStorageSync('IN_GZTID', GZTID)

				} else {
					this.GZTID = ''
					uni.removeStorageSync('IN_GZTID')
				}
				console.log("缓存中的入库工作站IN_GZTID:" + uni.getStorageSync('IN_GZTID'))

			},
			changeQuyNo(e) {
				this.form.quy_no = e
				uni.setStorageSync("inventory-check-quy_no", e)
				console.log("盘点缓存区域号:" + uni.getStorageSync("inventory-check-quy_no"))
			},
			changeKuf(e) {
				console.log("e:" + e);
				console.log("this.kufList:" + JSON.stringify(this.kufList))
				// const item = this.kufList[e];
				// console.log("item:"+item)
				this.form.kuf_no = e
				console.log(this.form.kuf_no)
				// 判断一下区域是不是在这个库房,如果在,就不更改区域,如果不在,就更改区域
				this.getKufbyKuf()
				this.notChangeQuyNo = e ? false : true

				uni.setStorageSync("inventory-check-kuf_no", e)
				console.log("盘点缓存库房号:" + uni.getStorageSync("inventory-check-kuf_no"))

			},
			// 查看选择到的库房的区域
			getKufbyKuf() {
				const USER_ID = uni.getStorageSync('USER_ID')
				const KUB = '%'
				const KUF_NO = this.form.kuf_no ? this.form.kuf_no : "%"
				//1获取库别，2获取库房，3获取区域
				const GET_TYPE = 3
				let param = USER_ID + "," + KUB + "," + KUF_NO + "," + GET_TYPE;
				console.log(param)
				this.$u.api.general({
						iv_code: "GETKUFQUYNO",
						iv_parm: param
					})
					.then(res => {
						console.log("getKufbyKuf返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("查看选择到的库房的区域返回的data:" + JSON.stringify(data))
						if (res.success) {

							this.form.quy_no = uni.getStorageSync("inventory-check-quy_no")
							console.log("this.form.quy_no:" + this.form.quy_no)
							let newData = [];
							if (this.form.quy_no) {
								//补充text
								newData = data.filter((item) => {
									// 过滤如果有对象的区域参数和已经够选择的区域no相同,那么就不用覆盖已经选择的
									return item.QUY_NO === this.form.quy_no
								})
							}

							if (newData.length > 0) {
								console.log("不用重新选择,这是从对象集合种筛出来的区域号相同的对象=>" + JSON.stringify(newData))
								this.quNoList = data.map(v => {
									this.$set(v, 'text', v.QUY_NO)
									this.$set(v, 'value', v.QUY_NO)
									return v
								})
							} else {
								console.log("重新选择,这是库房对应的对象集合,=>" + JSON.stringify(data))
								this.quNoList = data.map(v => {
									this.$set(v, 'text', v.QUY_NO)
									this.$set(v, 'value', v.QUY_NO)
									return v
								})
								//如果切换的区域
								this.form.quy_no = ''
							}
							this.canChangeQuy_no()
						} else {
							this.errContent = res.msg
							this.$u.toast(res.msg);
						}
					});
			},
			// 将区域可选
			canChangeQuy_no() {
				this.notChangeQuyNo = false
			},
			getGzt(loginType) {
				const user_id = uni.getStorageSync('USER_ID')
				const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				const kuf = "%"
				const gztType = "1"
				const gztId = "%"
				let param = user_id + "," + STORAGE_ID + "," + kuf + "," + gztType + "," + gztId;
				console.log(param)
				this.$u.api.general({
						iv_code: "GETGZTINFO",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("getGzt返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.gztList = data.map(v => {
								this.$set(v, 'text', v
									.GZTNAME + "(" + v.GZTID + ")"
								) // https://vuejs.org/v2/guide/reactivity.html
								return v
							})

							// 增加一条特殊的测试数据
							this.gztList.push({
								"text": "DHJ01",
								"WORKLOAD": "4",
								"CENG": "1",
								"GZT_TYPE": "1",
								"ISZCQFP": "N",
								"STORAGEID": "SU3",
								"WORKSTATION_TYPE": "0",
								"LETDOWNFLAG": "1",
								"GZTID": "DHJ01",
								"GZTNAME": "DHJ01测试工作站",
								"KUF_NO": "LHK"
							})
						} else {
							this.$u.toast(res.msg);
						}
					});
			},

		}

	}
</script>
<style lang="scss" scoped>
	@import '../../common/index.scss';
	@import '../../common/base-change.scss';
</style>